<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition template="../template/template.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<body>
	
	<!--Lista de Clientes Cadastrados -->
	
		<ui:define name="content">
			<h:form id="formListaClientes">
			
			<p:growl id="messages" showDetail="true"/> 
			
		      <p:dataTable style="width:1313px;" id="dataTable"  var="cliente" value="#{clienteMB.listaClientes}" widgetVar="carsTable"   
           		 editable="true" editMode="cell" emptyMessage="Não há clientes cadastrados." filteredValue="#{clienteMB.listaClientes}" 
           		 paginator="true" rows="17" >   
  				
  				<p:ajax event="cellEdit" listener="#{clienteMB.alterar}" update=":formListaClientes:messages" />
  				
  				<h:inputHidden id="hiddenId" value="#{cliente.id}" /> 	
  					
			    <p:column id="nome" headerText="Nome" styleClass="text_table" >
			    <p:cellEditor>  
		            <f:facet name="output"><h:outputText value="#{cliente.nome}" /> </f:facet>
		            <f:facet name="input"><h:inputText value="#{cliente.nome}" style="width:96%"/></f:facet> 
		        </p:cellEditor>
		        </p:column>  
		        <p:column id="cpf" styleClass="text_table" headerText="CPF">  
		         	<p:cellEditor>
		            <f:facet name="output"><h:outputText value="#{cliente.cpf}" /></f:facet>  
		            <f:facet name="input"><p:inputMask value="#{cliente.cpf}" mask="999.999.999-99"/></f:facet>
		            </p:cellEditor>
		        </p:column>  
		        <p:column id="cep" styleClass="text_table" headerText="CEP">  
		           <p:cellEditor>
		         	  <f:facet name="output"> <h:outputText value="#{cliente.cep}" /> </f:facet>
		         	  <f:facet name="input"><p:inputMask value="#{cliente.cep}" mask="99999-999" /></f:facet>
		           </p:cellEditor>
		        </p:column>  
		        <p:column id="bairro"  styleClass="text_table" headerText="Bairro">  
		        	<p:cellEditor>
		           	 <f:facet name="output"> <h:outputText value="#{cliente.bairro}" /> </f:facet> 
		           	 <f:facet name="input"><h:inputText value="#{cliente.bairro}" style="width:96%"/></f:facet>
		            </p:cellEditor>
		        </p:column>  
		        <p:column id="cidade" styleClass="text_table" headerText="Cidade">  
		        	<p:cellEditor>
		           	 <f:facet name="output"> <h:outputText value="#{cliente.cidade}" /></f:facet>
		           	  <f:facet name="input"><h:inputText value="#{cliente.cidade}" style="width:96%"/></f:facet>
		            </p:cellEditor>  
		        </p:column> 
		       
		        <p:column headerText="Vizualizar" >  
		           <p:commandButton id="cadastroId" update=":formListaClientes:modalCliente" oncomplete="modalCliente.show()" icon="icone_vizualizar" style="height:20px; margin-left:42%;" >
		           		<f:setPropertyActionListener  target="#{clienteMB.mostrarCliente}" value="#{cliente}"></f:setPropertyActionListener>
		           </p:commandButton> 
		                            
		          	
		        </p:column> 
  			</p:dataTable>  
    			
    			<ui:include src="../cadastro/mostrarCliente.xhtml"></ui:include>
    		</h:form>

</ui:define>

</body>
</ui:composition>
